import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Timer;  
import java.util.TimerTask;  
  

public class timetask {  
    public static void main(String[] args) {  
        TimerTask task = new TimerTask() {  
            @Override  
            public void run() {  
                // task to run goes here  
                System.out.println("Hello !!!");  
                try {
					Process p = Runtime.getRuntime().exec("java email",null,null);
					 
					InputStream in = p.getInputStream();  
		                BufferedReader read = new BufferedReader(new InputStreamReader(in));  
		                String line1 = null;  
		                p.waitFor();
		                while((line1 = read.readLine())!=null){  
		                    System.out.println(line1);  
		                }  
		                System.out.println("timetask程序运行结束");
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
            }  
        };  
        Timer timer = new Timer();  
        long delay = 8*60*60*1000;  
        long intevalPeriod = 24 * 60 * 60 * 1000;  
        //long intevalPeriod = 10 * 1000;
        // schedules the task to be run in an interval  
        timer.scheduleAtFixedRate(task, delay, intevalPeriod);  
    } // end of main  
}  